package com.shopping.dev.bo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
@ApiModel("响应结果")
public class CommonResultBO<T> implements Serializable {
    @ApiModelProperty("处理状态")
    private int status;
    @ApiModelProperty("失败描述")
    private String msg;
    @ApiModelProperty("返回参数")
    private T data;
    @ApiModelProperty("总页数")
    private int totalPage;
    @ApiModelProperty("每页长度")
    private int totalSize;

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
    public static CommonResultBO ok(Object data){
        CommonResultBO commonResultBO = new CommonResultBO();
        commonResultBO.setStatus(200);
        commonResultBO.setData(data);
        return commonResultBO;
    }
    public static CommonResultBO error(String msg){
        CommonResultBO commonResultBO = new CommonResultBO();
        commonResultBO.setStatus(500);
        commonResultBO.setMsg(msg);
        return commonResultBO;
    }
    public static CommonResultBO ok(){
        CommonResultBO commonResultBO = new CommonResultBO();
        commonResultBO.setStatus(200);
        return commonResultBO;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public int getTotalPage() {
        return totalPage;
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getTotalSize() {
        return totalSize;
    }

    public void setTotalSize(int totalSize) {
        this.totalSize = totalSize;
    }
}
